import {reactive, ref} from "vue";

export function Menu() {
    //菜单列表
    const menus = reactive({
        message: {
            title: "聊天",
            icon: "chat-message",
            iconActive: "chat-message-fill"
        },
        friends: {
            title: "通讯录",
            icon: "chat-customer",
            iconActive: "chat-customer-fill"
        },
        collect: {
            title: "收藏",
            icon: "chat-collect",
            iconActive: "chat-collect-fill"
        },
        files: {
            title: "聊天文件",
            icon: "chat-folder-open",
            iconActive: "chat-folder-open-fill"
        },
    })

    //当前展示的目录
    let activeMenu = ref("message");

    /**
     * 切换菜单
     * @param localMenu
     */
    function switchMenu(localMenu:string) {
        if (!menus.hasOwnProperty(localMenu)) {
            return;
        }

        if (localMenu === activeMenu.value) {
            return;
        }

        activeMenu.value = localMenu;
    }

    return {activeMenu, menus, switchMenu};
}